<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Confirm学习</title>
</head>
<body>
<h4>Confirm Test</h4>

<script type="text/javascript">
function showConfirm(){
    var t1 = document.f1.t1;
    if (confirm("Some question?")){
        t1.value = "oked";
    }else{
        t1.value = "canceled";
    }
}
</script>
<form name="f1">
    <input type="button" name="b1" value="Click For Confirm" onclick="showConfirm()"><br><br>
    <input type="text" name="t1">
</form>
<br>
</body>
</html>